home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / SYSTEM.H < prev    next >
C/C++ Source or Header  |  1993-03-16  |  8KB  |  302 lines

  1. /*    SCCS Id: @(#)system.h 3.0    88/10/10 */
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #ifndef SYSTEM_H
  6. #define SYSTEM_H
  7.  
  8. #define E extern
  9.  
  10. /* some old <sys/types.h> may not define off_t and size_t; if your system is
  11.  * one of these, define them by hand below
  12.  */
  13. #ifndef VAXC
  14. #if !defined(THINKC4) && !defined(AMIGA) && !defined(MACOS)
  15. # include <sys/types.h>
  16. #endif
  17. #else   /*VAXC*/
  18. #include <types.h>
  19. #endif  /*VAXC*/
  20.  
  21. #if defined(TOS) && defined(__GNUC__) && !defined(_SIZE_T)
  22. # define _SIZE_T
  23. #endif
  24.  
  25. #if defined(MSDOS) || ((defined(AMIGA) || defined(MACOS)) && !defined(THINKC4))
  26. # ifndef _SIZE_T
  27. #  define _SIZE_T
  28. #  if !(defined(MSDOS) && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */
  29. typedef unsigned int    size_t;
  30. #  endif
  31. # endif
  32. #endif
  33.  
  34. #ifdef ULTRIX
  35. /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
  36. # define time_t long
  37. #endif
  38. #if defined(ULTRIX) || defined(VMS)
  39. # define off_t long
  40. #endif
  41. #if defined(AZTEC) || defined(THINKC4) || (defined(MSDOS) && defined(__TURBOC__))
  42. typedef long    off_t;
  43. #endif
  44.  
  45.  
  46. /* You may want to change this to fit your system, as this is almost
  47.  * impossible to get right automatically.
  48.  * This is the type of signal handling functions.
  49.  */
  50. #if defined(__STDC__) || defined(ULTRIX)
  51.     /* also SVR3 and later, Sun4.0 and later */
  52. # define SIG_RET_TYPE void (*)()
  53. #else
  54.     /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
  55. # define SIG_RET_TYPE int (*)()
  56. #endif
  57.  
  58. #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
  59. E long random();
  60. E void FDECL(srandom, (unsigned int));
  61. #else
  62. E long lrand48();
  63. E void srand48();
  64. #endif /* BSD || ULTRIX || RANDOM */
  65.  
  66. #if !defined(BSD) || defined(ultrix)
  67.             /* real BSD wants all these to return int */
  68. # ifndef MSDOS
  69. E void FDECL(exit, (int));
  70. # endif /* MSDOS */
  71. E void FDECL(free, (genericptr_t));
  72. # if defined(AMIGA) && !defined(AZTEC_50)
  73. E int FDECL(perror, (const char *));
  74. # else
  75. #  ifndef MACOS
  76. E void FDECL(perror, (const char *));
  77. #  endif
  78. # endif
  79. #endif
  80. #if defined(BSD) || defined(ULTRIX) || (defined(MACOS) && !defined(THINKC4))
  81. E int qsort();
  82. #else
  83. # ifndef LATTICE
  84. E void FDECL(qsort, (genericptr_t,size_t,size_t,int(*)(genericptr_t,genericptr_t)));
  85. # endif
  86. #endif
  87.  
  88. #ifndef AZTEC_50    /* Already defined in include files */
  89. #ifdef ULTRIX
  90. E long FDECL(lseek, (int,off_t,int));
  91.   /* Ultrix 3.0 man page mistakenly says it returns an int. */
  92. E int FDECL(write, (int,char *,int));
  93. #else
  94. E long FDECL(lseek, (int,long,int));
  95. E int FDECL(write, (int,genericptr_t,unsigned));
  96. #endif /* ULTRIX */
  97. E int FDECL(unlink, (const char *));
  98.  
  99. #ifdef MSDOS
  100. E int FDECL(close, (int));
  101. E int FDECL(read, (int,genericptr_t,unsigned int));
  102. E int FDECL(open, (const char *,int,...));
  103. E int FDECL(dup2, (int, int));
  104. E int FDECL(setmode, (int,int));
  105. E int FDECL(kbhit, (void));
  106. E int FDECL(chdir, (char *));
  107. E char *FDECL(getcwd, (char *,int));
  108. #endif
  109. #endif  /* AZTEC_50 */
  110.  
  111. #ifdef TOS
  112. E int FDECL(creat, (const char *, int));
  113. #endif
  114.  
  115. /* both old & new versions of Ultrix want these, but real BSD does not */
  116. #ifdef ultrix
  117. E void abort();
  118. E void bcopy();
  119. #endif
  120. #ifdef MSDOS
  121. E void FDECL(abort, (void));
  122. E void FDECL(_exit, (int));
  123. E int FDECL(system, (const char *));
  124. #endif
  125. #ifdef HPUX
  126. E long FDECL(fork, (void));
  127. #endif
  128.  
  129. #ifdef SYSV
  130. E char *memcpy();
  131. #endif
  132. #ifdef HPUX
  133. E void *FDECL(memcpy, (char *,char *,int));
  134. E int FDECL(memcmp, (char *,char *,int));
  135. E void *FDECL(memset, (char*,int,int));
  136. #endif
  137. #ifdef MSDOS
  138. # if defined(TOS) && defined(__GNUC__)
  139. E int FDECL(memcmp, (const char *,const char *,size_t));
  140. E char *FDECL(memcpy, (char *,const char *,size_t));
  141. E char *FDECL(memset, (char*,int,size_t));
  142. # else
  143. #  ifndef LATTICE
  144. #    ifdef MSC
  145. void * _CDECL memcpy(void *, const void *, size_t);
  146. void * _CDECL memset(void *, int, size_t);
  147. #    else
  148. E int FDECL(memcmp, (char *,char *,unsigned int));
  149. E char *FDECL(memcpy, (char *,char *,unsigned int));
  150. E char *FDECL(memset, (char*,int,int));
  151. #    endif
  152. #  endif
  153. # endif /* TOS */
  154. #endif
  155.  
  156. #if defined(BSD) && defined(ultrix)    /* i.e., old versions of Ultrix */
  157. E void sleep();
  158. #endif
  159. #if defined(ULTRIX) || defined(SYSV)
  160. E unsigned sleep();
  161. #endif
  162. #if defined(HPUX)
  163. E unsigned int FDECL(sleep, (unsigned int));
  164. #endif
  165.  
  166. E char *FDECL(getenv, (const char *));
  167. E char *getlogin();
  168. #ifdef HPUX
  169. E long FDECL(getuid, (void));
  170. E long FDECL(getgid, (void));
  171. E long FDECL(getpid, (void));
  172. #else
  173. E int FDECL(getpid, (void));
  174. #endif
  175.  
  176. /*# string(s).h #*/
  177.  
  178. E char    *FDECL(strcpy, (char *,const char *));
  179. E char    *FDECL(strncpy, (char *,const char *,size_t));
  180. E char    *FDECL(strcat, (char *,const char *));
  181. E char    *FDECL(strncat, (char *,const char *,size_t));
  182.  
  183. #if defined(SYSV) || defined(MSDOS) || defined(AMIGA) || defined(THINK_C) || defined(VMS) || defined(HPUX)
  184. E char    *FDECL(strchr, (const char *,int));
  185. E char    *FDECL(strrchr, (const char *,int));
  186. #else /* BSD */
  187. E char    *FDECL(index, (const char *,int));
  188. E char    *FDECL(rindex, (const char *,int));
  189. #endif
  190.  
  191.  
  192. E int    FDECL(strcmp, (const char *,const char *));
  193. E int    FDECL(strncmp, (const char *,const char *,size_t));
  194. #ifdef MSDOS
  195. E size_t FDECL(strlen, (const char *));
  196. #else
  197. # ifdef HPUX
  198. E unsigned int    FDECL(strlen, (char *));
  199. # else
  200. #  ifdef THINKC4
  201. E size_t    FDECL(strlen, (char *));
  202. #  else
  203. E int    FDECL(strlen, (char *));
  204. #  endif /* THINKC4 */
  205. # endif /* HPUX */
  206. #endif /* MSDOS */
  207.  
  208. /* Old varieties of BSD have char *sprintf().
  209.  * Newer varieties of BSD have int sprintf() but allow for the old char *.
  210.  * Several varieties of SYSV and PC systems also have int sprintf().
  211.  * If your system doesn't agree with this breakdown, you may want to change
  212.  * this declaration, especially if your machine treats the types differently.
  213.  */
  214. #if (defined(BSD) || defined(ULTRIX)) && !defined(DGUX) && !defined(NeXT)
  215. # define OLD_SPRINTF
  216. E char *sprintf();
  217. #else
  218. # if !defined(TOS) && !defined(AZTEC_50) /* problem with prototype mismatches */
  219. E int FDECL(sprintf, (char *,const char *,...));
  220. # endif
  221. #endif
  222.  
  223. #ifdef NEED_VARARGS
  224. # if defined(USE_STDARG) || defined(USE_VARARGS)
  225. E int FDECL(vsprintf, (char *, const char *, va_list));
  226. E int FDECL(vprintf, (const char *, va_list));
  227. # else
  228. #  define vprintf    printf
  229. #  define vsprintf    sprintf
  230. #  define vpline    pline
  231. # endif
  232. #endif /* NEED_VARARGS */
  233.  
  234. #define Sprintf    (void) sprintf
  235. #define Strcat    (void) strcat
  236. #define Strcpy    (void) strcpy
  237.  
  238. #if defined(MACOS) && defined(CUSTOM_IO)
  239. # undef printf
  240. # undef puts
  241. # undef putchar
  242. # undef putc
  243. # define printf  (void) mprintf
  244. # define puts     mputs
  245. # define putchar mputc
  246. # define putc     mputc
  247. # define Printf  (void) mprintf
  248. #else
  249. # define Printf  (void) printf
  250. #endif
  251.  
  252. #ifdef NEED_VARARGS
  253. # define Vprintf (void) vprintf
  254. # define Vsprintf (void) vsprintf
  255. #endif
  256.  
  257. #ifdef MSDOS
  258. E int FDECL(tgetent, (const char *,const char *));
  259. E int FDECL(tgetnum, (const char *));
  260. E int FDECL(tgetflag, (const char *));
  261. E char *FDECL(tgetstr, (const char *,char **));
  262. E char *FDECL(tgoto, (const char *,int,int));
  263. E void FDECL(tputs, (const char *,int,int (*)()));
  264. #else
  265. E int FDECL(tgetent, (char *,char *));
  266. E int FDECL(tgetnum, (char *));
  267. E int FDECL(tgetflag, (char *));
  268. E char *FDECL(tgetstr, (char *,char **));
  269. E char *FDECL(tgoto, (char *,int,int));
  270. E void FDECL(tputs, (char *,int,int (*)()));
  271. #endif
  272.  
  273. #ifndef MACOS
  274. E genericptr_t FDECL(malloc, (size_t));
  275. #endif
  276.  
  277. /* time functions */
  278.  
  279. #ifndef MACOS
  280. # ifndef LATTICE
  281. E struct tm *FDECL(localtime, (const time_t *));
  282. # endif
  283.  
  284. # if defined(ULTRIX) || defined(SYSV) || defined(MSDOS) || defined(VMS)
  285. E time_t FDECL(time, (time_t *));
  286. # else
  287. E long FDECL(time, (time_t *));
  288. # endif /* ULTRIX */
  289. #endif
  290.  
  291. #ifdef MSDOS
  292. # ifdef abs
  293. # undef abs
  294. # endif
  295. E int FDECL(abs, (int));
  296. E int FDECL(atoi, (const char *));
  297. #endif
  298.  
  299. #undef E
  300.  
  301. #endif /* SYSTEM_H */
  302.